package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhAfterFactoryAddress;
import com.ruoyi.zsyh.service.IZsyhAfterFactoryAddressService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 售后厂家收货地址Controller
 * 
 * @author yuexl
 * @date 2023-06-29
 */
@Controller
@RequestMapping("/zsyh/afterFactoryAddress")
public class ZsyhAfterFactoryAddressController extends BaseController
{
    private String prefix = "zsyh/afterFactoryAddress";

    @Autowired
    private IZsyhAfterFactoryAddressService zsyhAfterFactoryAddressService;

    @RequiresPermissions("zsyh:afterFactoryAddress:view")
    @GetMapping()
    public String afterFactoryAddress()
    {
        return prefix + "/afterFactoryAddress";
    }

    /**
     * 查询售后厂家收货地址列表
     */
    @RequiresPermissions("zsyh:afterFactoryAddress:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhAfterFactoryAddress zsyhAfterFactoryAddress)
    {
        startPage();
        //获取所有的列表信息
        List<ZsyhAfterFactoryAddress> list = zsyhAfterFactoryAddressService.selectZsyhAfterFactoryAddressList(zsyhAfterFactoryAddress);
        return getDataTable(list);
    }

    /**
     * 导出售后厂家收货地址列表
     */
    @RequiresPermissions("zsyh:afterFactoryAddress:export")
    @Log(title = "售后厂家收货地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhAfterFactoryAddress zsyhAfterFactoryAddress)
    {
        List<ZsyhAfterFactoryAddress> list = zsyhAfterFactoryAddressService.selectZsyhAfterFactoryAddressList(zsyhAfterFactoryAddress);
        ExcelUtil<ZsyhAfterFactoryAddress> util = new ExcelUtil<ZsyhAfterFactoryAddress>(ZsyhAfterFactoryAddress.class);
        return util.exportExcel(list, "售后厂家收货地址数据");
    }

    /**
     * 新增售后厂家收货地址
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存售后厂家收货地址
     */
    @RequiresPermissions("zsyh:afterFactoryAddress:add")
    @Log(title = "售后厂家收货地址", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhAfterFactoryAddress zsyhAfterFactoryAddress)
    {
        return toAjax(zsyhAfterFactoryAddressService.insertZsyhAfterFactoryAddress(zsyhAfterFactoryAddress));
    }

    /**
     * 修改售后厂家收货地址
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhAfterFactoryAddress zsyhAfterFactoryAddress = zsyhAfterFactoryAddressService.selectZsyhAfterFactoryAddressById(id);
        mmap.put("zsyhAfterFactoryAddress", zsyhAfterFactoryAddress);
        return prefix + "/edit";
    }

    /**
     * 修改保存售后厂家收货地址
     */
    @RequiresPermissions("zsyh:afterFactoryAddress:edit")
    @Log(title = "售后厂家收货地址", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhAfterFactoryAddress zsyhAfterFactoryAddress)
    {
        return toAjax(zsyhAfterFactoryAddressService.updateZsyhAfterFactoryAddress(zsyhAfterFactoryAddress));
    }

    /**
     * 删除售后厂家收货地址
     */
    @RequiresPermissions("zsyh:afterFactoryAddress:remove")
    @Log(title = "售后厂家收货地址", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhAfterFactoryAddressService.deleteZsyhAfterFactoryAddressByIds(ids));
    }
}
